package cn.tedu.cake.shop.product.controller;

import cn.tedu.cake.shop.product.pojo.param.BreadAddNewParam;
import cn.tedu.cake.shop.product.service.BreadService;
import cn.tedu.cake.shop.product.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/bread")
@Slf4j
@Api(tags = "02.面包管理模块")
@Validated
public class BreadController {

    @Autowired
    BreadService breadService;

    @PostMapping("/add-new")
    @ApiOperation("添加面包")
    @ApiOperationSupport(order = 100)
    public JsonResult addNew(@Valid BreadAddNewParam breadAddNewParam){
        log.debug("开始处理【添加面包】的请求，参数:{}",breadAddNewParam);
        breadService.addNew(breadAddNewParam);
        return JsonResult.ok();
    }
}
